package win.ganbo.softwareFive.controller;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.jasig.cas.client.util.AbstractCasFilter;
import org.jasig.cas.client.validation.Assertion;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import win.ganbo.softwareFive.listener.Member;
import win.ganbo.softwareFive.utils.ConstantConfig;

@Controller
@RequestMapping
public class CasClientController {

    @RequestMapping("/index")
    public String casclienttest() {
        System.out.println("公共资源");
        return "casclienttest";
    }

    @RequestMapping("/protected")
    public String protectedR(HttpServletRequest request) {
        System.out.println("保护资源");
        Member member = (Member) request.getSession().getAttribute(ConstantConfig.USER_IN_SESSION);
        System.out.print("controller====>" + member);
        System.out.println("sessionId====>" + request.getSession().getId());
        request.getSession().setAttribute("aaaa", "aaaaa");

        Assertion as = (Assertion) request.getSession()
            .getAttribute(AbstractCasFilter.CONST_CAS_ASSERTION);
        Map<String, Object> map = as.getPrincipal().getAttributes();
        System.out.println("map===>" + map);
        return "protected";
    }

}
